﻿<%@ Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="MostPlanets.aspx.cs" Inherits="smallDeimos.MostPlanets" Title="Small Deimos - most planets ranking" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="PlayerName" HeaderText="PlayerName" 
                    SortExpression="PlayerName" />
                <asp:BoundField DataField="Number of planets" HeaderText="Number of planets" 
                    ReadOnly="True" SortExpression="Number of planets" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>" 
            SelectCommand="SELECT DISTINCT TOP (50) Players.PlayerName, (SELECT COUNT(*) AS Expr1 FROM Planets WHERE (OwnerID = Players.PlayerId)) AS 'Number of planets' FROM Planets AS Planets_1 INNER JOIN Players ON Planets_1.OwnerID = Players.PlayerId WHERE (Players.PlayerId &gt; 1) ORDER BY 'Number of planets' DESC">
        </asp:SqlDataSource>
    </div>
</asp:Content>
